package com;

import com.Tokiu.Dao.BookDao;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) throws InterruptedException {
        //加载配置文件获取容器对象
        ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml.bat");

//        BaoInter service=new BaoService();
//        service.add();
        //加载配置文件获取容器对象
//        ClassPathXmlApplicationContext cts = new ClassPathXmlApplicationContext("applicationContext.xml.bat");
//
//        //设置关闭钩子
//        //关闭钩子在全局有效且温和
//        cts.registerShutdownHook();
//
//        //获取资源
//        BaoDao dao = (BaoDao) cts.getBean("Dao");
//
//        dao.save();

        //ClassPathXmlApplicationContext对象用close方法比较暴力
//        cts.close();

        ctx.registerShutdownHook();

//        BookDao bookDao = (BookDao) ctx.getBean("bookDao");
//
//        bookDao.add();


//        ctx.registerShutdownHook();
//
//        BaoService service = (BaoService) ctx.getBean("Service");
//
//        service.add();

//        DataSource dataSource= (DataSource) ctx.getBean("dataSource");
//
//        System.out.println(dataSource);
    }
}
